import axios, { AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from "axios";

const instance = axios.create({
  baseURL: 'http://127.0.0.1:8888/api/private/v1/',
  timeout: 100000
})

instance.interceptors.request.use((config: AxiosRequestConfig): AxiosRequestConfig => {
  (config.headers as AxiosRequestHeaders).Authorization = window.sessionStorage.getItem('token') + ''
  return config
}, err => {
  return Promise.reject(err)
})


instance.interceptors.response.use((response: AxiosResponse): AxiosResponse => {
  return response.data
}, err => {
  return Promise.reject(err)
})

export default instance;
